package com.sun.rabbit.util;

import java.io.ByteArrayInputStream;
import java.io.ObjectInputStream;

/**
 * @Author 喻湘东
 * @Create 2019-10-09 17:17:13
 */
public class ObjectUtil {

    public static <T>T getObjectFromBytes(byte[] objBytes) throws Exception {
        if (objBytes == null || objBytes.length == 0) {
            return null;
        }
        ByteArrayInputStream bi = new ByteArrayInputStream(objBytes);
        ObjectInputStream oi = new ObjectInputStream(bi);
        return (T) oi.readObject();
    }

}
